#pragma once
#include "../vfs/FileDeviceHandle.h"

namespace ja2{ namespace vfs
{
	//! File handle implementation for library file.
	class FileDeviceHandleLibrary : public FileDeviceHandle
	{
		// Attributes
	private:
		//! Begin position of stream.
		long long const m_BeginPos;
		//! End position of stream.
		long long const m_EndPos;
		//! Actual position.
		long long m_ActualPosition;
		//! Stream for reading.
		std::ifstream &m_Stream;

		// Operations
	private:
		//! See base.
		virtual std::streamsize read(char *Buffer, std::streamsize Size);
		//! See base.
		virtual std::streamsize write(const char* Buffer, std::streamsize Size);
		//! See base.
		virtual boost::iostreams::stream_offset seek(boost::iostreams::stream_offset Offset, std::ios_base::seekdir Direction);
		//! See base.
		virtual void open(std::ios_base::openmode mode);
		//! See base.
		virtual bool is_open() const;
		//! See base.
		virtual void close();
		//! Seek to right position.
		void seek(long long Position);

		// Construction/Destruction
	public:
		FileDeviceHandleLibrary(std::ifstream &Stream, std::string const &Name, long long Begin, long long End);
	};
} /*vfs*/} /*ja2*/
